home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / gawk / cawf2st.zoo / store.c < prev    next >
C/C++ Source or Header  |  1992-04-12  |  10KB  |  177 lines

  1. /*
  2.  *      store.c - cawf(1) storage areas
  3.  */
  4.  
  5. /*
  6.  *      Copyright (c) 1991 Purdue University Research Foundation,
  7.  *      West Lafayette, Indiana 47907.  All rights reserved.
  8.  *
  9.  *      Written by Victor A. Abell <abe@mace.cc.purdue.edu>,  Purdue
  10.  *      University Computing Center.  Not derived from licensed software;
  11.  *      derived from awf(1) by Henry Spencer of the University of Toronto.
  12.  *
  13.  *      Permission is granted to anyone to use this software for any
  14.  *      purpose on any computer system, and to alter it and redistribute
  15.  *      it freely, subject to the following restrictions:
  16.  *
  17.  *      1. The author is not responsible for any consequences of use of
  18.  *         this software, even if they arise from flaws in it.
  19.  *
  20.  *      2. The origin of this software must not be misrepresented, either
  21.  *         by explicit claim or by omission.  Credits must appear in the
  22.  *         documentation.
  23.  *
  24.  *      3. Altered versions must be plainly marked as such, and must not
  25.  *         be misrepresented as being the original software.  Credits must
  26.  *         appear in the documentation.
  27.  *
  28.  *      4. This notice may not be removed or altered.
  29.  */
  30.  
  31. #include "cawf.h"
  32.  
  33. struct rx Pat[] = {
  34.         { "^\\.(i[ef]|el)",                             NULL},  /* 0 */
  35.         { "^\\.i[ef] !",                                NULL},  /* 1 */
  36.         { "^\\.i[ef] !?\\\\n\\(\\.\\$[<=>][0-9] ",      NULL},  /* 2 */
  37.         { "^\\.i[ef] !?'\\\\\\$[0-9]'[^']*' ",          NULL},  /* 3 */
  38.         { "^\\.i[ef] !?[nt] ",                          NULL},  /* 4 */
  39.         { "\\\\\\$[0-9]",                               NULL},  /* 5 */
  40.         { "^[ \t]*$",                                   NULL},  /* 6 */
  41.         { "\\\\|\t|-|  ",                               NULL},  /* 7 */
  42.         { "[.!?:][]\\)'\\\"\\*]*$",                     NULL},  /* 8 */
  43.         { ",fP",                                        NULL},  /* 9 */
  44.         { ",tP",                                        NULL},  /* 10 */
  45.         { "^(ta|ll|ls|in|ti|po|ne|sp|pl|nr)",           NULL},  /* 11 */
  46.         { "^(ll|ls|in|ti|po|pl)",                       NULL},  /* 12 */
  47.         { "[]\\)'\\\"\\*]",                             NULL},  /* 13 */
  48.         { "^(LH|CH|RH|LF|CF|RF)",                       NULL},  /* 14 */
  49.         { "^\\.i[ef]",                                  NULL},  /* 15 */
  50.         { NULL,                                         NULL}   /* END */
  51. };
  52.  
  53. int Adj = BOTHADJ;                      /* output line adjustment mode */
  54. char *Aftnxt = NULL;                    /* action after next line */
  55. char *Args[] = {NULL, NULL,             /* 10 macro arguments */
  56.                 NULL, NULL,
  57.                 NULL, NULL,
  58.                 NULL, NULL,
  59.                 NULL, NULL};
  60. char *Argstack[10*MAXSP];               /* stack for Expand()'s "args[]" */
  61. int Backc = 0;                          /* last word ended with '\\c' */
  62. int Botmarg = 5;                        /* bottom margin */
  63. int Centering = 0;                      /* centering count */
  64. int Condstack[MAXSP];                   /* stack for Expand()'s "cond" */
  65. char *Cont = NULL;                      /* continue line append */
  66. int Contlen = 0;                        /* continue line append length */
  67. int Curmx = -1;                         /* current macro index */
  68. int Divert = 0;                         /* diversion status */
  69. FILE *Efs = NULL;                       /* error file stream */
  70. char *Eol = NULL;                       /* end of line information */
  71. int Eollen = 0;                         /* end of line length */
  72. int Err = 0;                            /* error flag */
  73. char *F = NULL;                         /* field value */
  74. struct fcode Fcode[] = {                /* font codes */
  75.         { 'B',  '\0'},                  /* Bold */
  76.         { 'I',  '\0'},                  /* Italic */
  77.         { 'R',  '\0'},                  /* Roman */
  78.         { '\0', '\0'}
  79. };
  80. int Fill = 0;                           /* fill status */
  81. char Font[] = { '\0', '\0' };           /* current font */
  82. char Fontout = 'b';                     /* font output mode: 'n' = none
  83.                                          *                   'b' = BS & UL
  84.                                          *                   'e' = ESC & code */
  85. int Fph = 0;                            /* first page header status */
  86. int Fsp = 0;                            /* files stack pointer (for .so) */
  87. char *Ftc = NULL;                       /* center footer */
  88. char *Ftl = NULL;                       /* left footer */
  89. char *Ftr = NULL;                       /* right footer */
  90. char *Hdc = NULL;                       /* center header */
  91. int Hdft = 0;                           /* header/footer status */
  92. char *Hdl = NULL;                       /* left header */
  93. char *Hdr = NULL;                       /* right header */
  94. struct hytab Hychar[MAXHYCH];           /* hyphen characters */
  95. FILE *Ifs = NULL;                       /* input file stream */
  96. FILE *Ifs_stk[MAXFSTK];                 /* Ifs stack */
  97. int Ind = 0;                            /* indentation amount */
  98. char *Inname = NULL;                    /* input file name */
  99. char *Inn_stk[MAXFSTK];                 /* Inname stack */
  100. int LL = 78;                            /* line length (default) */
  101. char Line[MAXLINE];                     /* input line */
  102. int Lockil = 0;                         /* pass 2 line number is locked
  103.                                          * (processing is inside macro) */
  104. int Marg = 0;                           /* macro argument - man, ms, etc. */
  105. struct macro Macrotab[MAXMACRO];        /* macro table */
  106. char *Macrotxt[MAXMTXT];                /* macro text */
  107. int Mtx = 0;                            /* macro text index */
  108. int Mxstack[MAXSP];                     /* stack for Expand()'s "mx" */
  109. int Nfc;                                /* number of font codes */
  110. int Nhnr[MAXNHNR];                      /* ".NH" numbers */
  111. int Nhy = 0;                            /* number of Hychar[] entries */
  112. int Nleftstack[MAXSP];                  /* stack for Expand()'s "nleft" */
  113. int Nmac = 0;                           /* number of macros */
  114. int Nnr = 0;                            /* number of Numb[] entries */
  115. int Nospmode = 1;                       /* no space mode */
  116. int Nparms = 0;                         /* number of Parms[] entries */
  117. int NR = 0;                             /* number of record ala awk */
  118. int NR_stk[MAXFSTK];                    /* NR stack */
  119. int Nsch = 0;                           /* number of Schar[] entries */
  120. int Nstr = 0;                           /* number of entries in Str[] */
  121. int Ntabs = 0;                          /* number of TAB positions */
  122. struct nbr Numb[MAXNR];                 /* number registers */
  123. int Nxtln = 1;                          /* next line number */
  124. int Outll = -1;                         /* output line length */
  125. char Outln[MAXOLL*2];                   /* output line */
  126. int Outlx = 0;                          /* output line index */
  127. int P2il = 0;                           /* pass 2 input line number */
  128. char *P2name = NULL;                    /* pass 2 input file name */
  129. int P3fill = 1;                         /* pass 3 fill status */
  130. int Padchar[MAXOLL];                    /* padding character locations */
  131. int Padfrom = PADLEFT;                  /* which end to pad from */
  132. int Padx = 0;                           /* Padchar[] index */
  133. struct parms Parms[] = {                /* parameter registers */
  134.         { {'i', 'n'}, "indent", 0, 0      },
  135.         { {'l', 'l'}, "linelen", 0, 0     },
  136.         { {'l', 's'}, "vspace", 0, 0      },
  137.         { {'t', 'i'}, "tempindent", 0, 0  },
  138.         { {'p', 'o'}, "pageoffset", 0, 0  },
  139.         { {'p', 'l'}, "pagelen", 0, 0     },
  140.         { {'\0', '\0'}, NULL, 0, 0        }
  141. };
  142. char Pass1ln[MAXLINE];                  /* pass 1 output line */
  143. char Pass2ln[MAXLINE];                  /* pass 2 output line */
  144. int Pglen = 66;                         /* page length */
  145. int Pgoff = 0;                          /* page offset */
  146. char *Pname = NULL;                     /* program name */
  147. char Prevfont = '\0';                   /* previous font */
  148. int Ptrstack[MAXSP];